const db = uniCloud.database()
const dbCmd = db.command
const {
	zmfAccountInfoCollection
} = require('../../../common/constants')
const {
	ERROR
} = require('../../../common/error')

/**
 * 获取账户信息
 */
module.exports = async function(params = {}) {
	const schema = {
		uid: 'string',
		type: {
		  required: false,
		  type: 'string'
		},
		expire_date: {
		  required: false,
		  type: 'number'
		},
	}
	this.middleware.validate(params, schema)
	const {
		uid,type,expire_date
	} = params
	
	const resp = await zmfAccountInfoCollection.where({
		uid:uid,
		type:type,
		expire_date:dbCmd.gt(expire_date)
	})
	.orderBy("source",'asc')
	.orderBy("expire_date",'asc')
	.get()
	const userRecord = resp && resp.data ? resp.data : {}
	return {
		errCode: 0,
		userRecord: userRecord
	}
}